public class MaxArea {
    // 盛最多水的容器
    // https://leetcode.cn/problems/container-with-most-water/description/?envType=study-plan-v2&envId=top-100-liked
    public int maxArea(int[] height) {
        int left = 0, right = height.length-1;
        int ret = 0;
        while (left < right) {
            ret = Math.max(Math.min(height[left], height[right]) * (right-left), ret);
            if (height[left] > height[right]) {
                right--;
            } else {
                left++;
            }
        }
        return ret;
    }
}
